home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / binsrclib / kgraph.c next >
Encoding:
C/C++ Source or Header  |  1989-12-08  |  13.1 KB  |  804 lines

  1. /* %W%    %G% */
  2. /* Modified graph.c                            */
  3. /* Modification time: 1987.9.14                */
  4. /* Modified Features:                          */
  5. /* (1)Double Precision is allowed              */
  6. /* (2)Frame is thicker                         */
  7. /* (3)Max and min x & y are shown on top       */
  8. /* (4)The position of a symbol . is readjusted */ 
  9. /*    to conform with a point from "point" */
  10. /*    c plotting subroutine.                   */
  11. /* (5)change of defaults -g 1 -m 0             */
  12. /* (6)changed log10(x) to log(x)/log(10)       */
  13.  
  14. #ifndef lint
  15. static char sccsid[] = "@(#)graph.c    4.2 3/30/83";
  16. #endif
  17.  
  18.  
  19. #include <stdio.h>
  20. #include <ctype.h>
  21. #include <math.h>
  22. #define    INF    HUGE
  23. #define    F    .25
  24.  
  25. struct xy {
  26.     int    xlbf;    /*flag:explicit lower bound*/
  27.     int     xubf;    /*flag:explicit upper bound*/
  28.     int    xqf;    /*flag:explicit quantum*/
  29.     double (*xf)();    /*transform function, e.g. log*/
  30.     double    xa,xb;    /*scaling coefficients*/
  31.     double    xlb,xub;    /*lower and upper bound*/
  32.     double    xquant;    /*quantum*/
  33.     double    xoff;        /*screen offset fraction*/
  34.     double    xsize;        /*screen fraction*/
  35.     int    xbot,xtop;    /*screen coords of border*/    
  36.     double    xmult;    /*scaling constant*/
  37. } xd,yd;
  38. struct val {
  39.     double xv;
  40.     double yv;
  41.     int lblptr;
  42. } *xx;
  43.  
  44. char *labs;
  45. int labsiz;
  46.  
  47. int tick = 50;
  48. /* figure maximizing choice
  49. int top = 4084;
  50. int bot = 284;
  51. */
  52. /* original configuration */
  53. int top = 4000;
  54. int bot = 200;
  55. double absbot;
  56. int    n;
  57. int    erasf = 1;
  58. int    gridf = 1;
  59. int    symbf = 0;
  60. int    absf = 0;
  61. int    transf;
  62. int    brkf;
  63. double    dx;
  64. char    *plotsymb;
  65.  
  66. double    atof();
  67. #define BSIZ 160
  68. #define MAXLINE 10
  69. char    labbuf[BSIZ];
  70. char    headerfile[BSIZ];
  71. char    titlebuf[MAXLINE][BSIZ];
  72.  
  73. char *modes[] = {
  74.     "disconnected",
  75.     "solid",
  76.     "dotted",
  77.     "dotdashed",
  78.     "shortdashed",
  79.     "longdashed"
  80. };
  81. int mode = 0;
  82. char *realloc();
  83. char *malloc();
  84.  
  85. double ident(x)
  86. double x;
  87. {
  88.     return(x);
  89. }
  90.  
  91. main(argc,argv)
  92. char *argv[];
  93. {
  94.  
  95.     space(0,0,4096,4096);
  96.     init(&xd);
  97.     init(&yd);
  98.     xd.xsize = yd.xsize = 1.;
  99.     xx = (struct val *)malloc((unsigned)sizeof(struct val));
  100.     labs = malloc(1);
  101.     labs[labsiz++] = 0;
  102.     setopt(argc,argv);
  103.     if(erasf)
  104.         erase();
  105.     readin();
  106.     transpose();
  107.     scale(&xd,(struct val *)&xx->xv);
  108.     scale(&yd,(struct val *)&xx->yv);
  109.     axes();
  110.     title();
  111.     plot();
  112.     move(1,1);
  113.     closevt();
  114.     return(0);
  115. }
  116.  
  117. init(p)
  118. struct xy *p;
  119. {
  120.     p->xf = ident;
  121.     p->xmult = 1;
  122. }
  123.  
  124. setopt(argc,argv)
  125. char *argv[];
  126. {
  127.     int i;
  128.     char *ph1, *ph2;
  129.     char *p1, *p2;
  130.     char *p12, *p22;
  131.     char *p13, *p23;
  132.     char *p14, *p24;
  133.     char *p15, *p25;
  134.     double temp;
  135.     FILE *fp,*fopen();
  136.  
  137.     xd.xlb = yd.xlb = INF;
  138.     xd.xub = yd.xub = -INF;
  139.     while(--argc > 0) {
  140.         argv++;
  141. again:        switch(argv[0][0]) {
  142.         case '-':
  143.             argv[0]++;
  144.             goto again;
  145.         case 'j': /* label for plot */
  146.             p1 = titlebuf[0];
  147.             if (argc>=2) {
  148.                 argv++;
  149.                 argc--;
  150.                 p2 = argv[0];
  151.                 while (*p1++ = *p2++);
  152.             }
  153.             break;
  154.         case 'k': /* label for plot */
  155.             p12 = titlebuf[1];
  156.             if (argc>=2) {
  157.                 argv++;
  158.                 argc--;
  159.                 p22 = argv[0];
  160.                 while (*p12++ = *p22++);
  161.             }
  162.             break;
  163.         case 'l': /* label for plot */
  164.             p13 = titlebuf[2];
  165.             if (argc>=2) {
  166.                 argv++;
  167.                 argc--;
  168.                 p23 = argv[0];
  169.                 while (*p13++ = *p23++);
  170.             }
  171.             break;
  172.         case 'n': /* label for plot */
  173.             p14 = titlebuf[3];
  174.             if (argc>=2) {
  175.                 argv++;
  176.                 argc--;
  177.                 p24 = argv[0];
  178.                 while (*p14++ = *p24++);
  179.             }
  180.             break;
  181.         case 'o': /* label for plot */
  182.             p15 = titlebuf[4];
  183.             if (argc>=2) {
  184.                 argv++;
  185.                 argc--;
  186.                 p25 = argv[0];
  187.                 while (*p15++ = *p25++);
  188.             }
  189.             break;
  190.         case 'f': /* read headers from a file */
  191.             strcpy(headerfile,argv[1]);
  192.             argv++;
  193.             argc--;
  194.             fp = fopen(headerfile,"r");
  195.             if(fp == NULL){
  196.                 printf("The specified header file is not found!\n");
  197.                 exit(-1);
  198.             }
  199.             i=0;
  200.             while(i<MAXLINE && (fgets(titlebuf[i],BSIZ,fp))!= NULL){
  201.                 titlebuf[i][(int)strlen(titlebuf[i])-1]= '\0';
  202.                 i++;
  203.             }
  204.             fclose(fp);
  205.             break;
  206.         case 'd':    /*disconnected,obsolete option*/
  207.         case 'm': /*line mode*/
  208.             mode = 0;
  209.             if(!numb(&temp,&argc,&argv))
  210.                 break;
  211.             if(temp>=sizeof(modes)/sizeof(*modes))
  212.                 mode = 1;
  213.             else if(temp>=0)
  214.                 mode = temp;
  215.             break;
  216.  
  217.         case 'a': /*automatic abscissas*/
  218.             absf = 1;
  219.             dx = 1;
  220.             if(!numb(&dx,&argc,&argv))
  221.                 break;
  222.             if(numb(&absbot,&argc,&argv))
  223.                 absf = 2;
  224.             break;
  225.  
  226.         case 's': /*save screen, overlay plot*/
  227.             erasf = 0;
  228.             break;
  229.  
  230.         case 'g': /*grid style 0 none, 1 ticks, 2 full*/
  231.             gridf = 0;
  232.             if(!numb(&temp,&argc,&argv))
  233.                 temp = argv[0][1]-'0';    /*for caompatibility*/
  234.             if(temp>=0&&temp<=2)
  235.                 gridf = temp;
  236.             break;
  237.  
  238.         case 'c': /*character(s) for plotting*/
  239.             if(argc >= 2) {
  240.                 symbf = 1;
  241.                 plotsymb = argv[1];
  242.                 argv++;
  243.                 argc--;
  244.             }
  245.             break;
  246.  
  247.         case 't':    /*transpose*/
  248.             transf = 1;
  249.             break;
  250.         case 'b':    /*breaks*/
  251.             brkf = 1;
  252.             break;
  253.         case 'x':    /*x limits */
  254.             limread(&xd,&argc,&argv);
  255.             break;
  256.         case 'y':
  257.             limread(&yd,&argc,&argv);
  258.             break;
  259.         case 'h': /*set height of plot */
  260.             if(!numb(&yd.xsize, &argc,&argv))
  261.                 badarg();
  262.             break;
  263.         case 'w': /*set width of plot */
  264.             if(!numb(&xd.xsize, &argc, &argv))
  265.                 badarg();
  266.             break;
  267.         case 'r': /* set offset to right */
  268.             if(!numb(&xd.xoff, &argc, &argv))
  269.                 badarg();
  270.             break;
  271.         case 'u': /*set offset up the screen*/
  272.             if(!numb(&yd.xoff,&argc,&argv))
  273.                 badarg();
  274.             break;
  275.         default:
  276.             badarg();
  277.         }
  278.     }
  279. }
  280.  
  281. limread(p, argcp, argvp)
  282. register struct xy *p;
  283. int *argcp;
  284. char ***argvp;
  285. {
  286.     if(*argcp>1 && (*argvp)[1][0]=='l') {
  287.         (*argcp)--;
  288.         (*argvp)++;
  289.         p->xf = log10;
  290.     }
  291.     if(!numb(&p->xlb,argcp,argvp))
  292.         return;
  293.     p->xlbf = 1;
  294.     if(!numb(&p->xub,argcp,argvp))
  295.         return;
  296.     p->xubf = 1;
  297.     if(!numb(&p->xquant,argcp,argvp))
  298.         return;
  299.     p->xqf = 1;
  300. }
  301.  
  302. numb(np, argcp, argvp)
  303. int *argcp;
  304. double *np;
  305. register char ***argvp;
  306. {
  307.     register char c;
  308.  
  309.     if(*argcp <= 1)
  310.         return(0);
  311.     while((c=(*argvp)[1][0]) == '+')
  312.         (*argvp)[1]++;
  313.     if(!(isdigit(c) || c=='-'&&(*argvp)[1][1]<'A' || c=='.'))
  314.         return(0);
  315.     *np = atof((*argvp)[1]);
  316.     (*argcp)--;
  317.     (*argvp)++;
  318.     return(1);
  319. }
  320.  
  321. readin()
  322. {
  323.     register t;
  324.     struct val *temp;
  325.  
  326.     if(absf==1) {
  327.         if(xd.xlbf)
  328.             absbot = xd.xlb;
  329.         else if(xd.xf==log10)
  330.             absbot = 1;
  331.     }
  332.     for(;;) {
  333.         temp = (struct val *)realloc((char*)xx,
  334.             (unsigned)(n+1)*sizeof(struct val));
  335.         if(temp==0)
  336.             return;
  337.         xx = temp;
  338.         if(absf)
  339.             xx[n].xv = n*dx + absbot;
  340.         else
  341.             if(!getdouble(&xx[n].xv))
  342.                 return;
  343.         if(!getdouble(&xx[n].yv))
  344.             return;
  345.         xx[n].lblptr = -1;
  346.         t = getstring();
  347.         if(t>0)
  348.             xx[n].lblptr = copystring(t);
  349.         n++;
  350.         if(t<0)
  351.             return;
  352.     }
  353. }
  354.  
  355. transpose()
  356. {
  357.     register i;
  358.     double f;
  359.     struct xy t;
  360.     if(!transf)
  361.         return;
  362.     t = xd; xd = yd; yd = t;
  363.     for(i= 0;i<n;i++) {
  364.         f = xx[i].xv; xx[i].xv = xx[i].yv; xx[i].yv = f;
  365.     }
  366. }
  367.  
  368. copystring(k)
  369. {
  370.     register char *temp;
  371.     register i;
  372.     int q;
  373.  
  374.     temp = realloc(labs,(unsigned)(labsiz+1+k));
  375.     if(temp==0)
  376.         return(0);
  377.     labs = temp;
  378.     q = labsiz;
  379.     for(i=0;i<=k;i++)
  380.         labs[labsiz++] = labbuf[i];
  381.     return(q);
  382. }
  383.  
  384. double
  385. modceil(f,t)
  386. double f,t;
  387. {
  388.  
  389.     t = fabs(t);
  390.     return(ceil(f/t)*t);
  391. }
  392.  
  393. double
  394. modfloor(f,t)
  395. double f,t;
  396. {
  397.     t = fabs(t);
  398.     return(floor(f/t)*t);
  399. }
  400.  
  401. getlim(p,v)
  402. register struct xy *p;
  403. struct val *v;
  404. {
  405.     register i;
  406.  
  407.     i = 0;
  408.     do {
  409.         if(!p->xlbf && p->xlb>v[i].xv)
  410.             p->xlb = v[i].xv;
  411.         if(!p->xubf && p->xub<v[i].xv)
  412.             p->xub = v[i].xv;
  413.         i++;
  414.     } while(i < n);
  415. }
  416.  
  417. struct z {
  418.     double lb,ub,mult,quant;
  419. } setloglim(), setlinlim();
  420.  
  421. setlim(p)
  422. register struct xy *p;
  423. {
  424.     double t,delta,sign;
  425.     struct z z;
  426.     int mark[50];
  427.     double lb,ub;
  428.     int lbf,ubf;
  429.  
  430.     lb = p->xlb;
  431.     ub = p->xub;
  432.     delta = ub-lb;
  433.     if(p->xqf) {
  434.         if(delta*p->xquant <=0 )
  435.             badarg();
  436.         return;
  437.     }
  438.     sign = 1;
  439.     lbf = p->xlbf;
  440.     ubf = p->xubf;
  441.     if(delta < 0) {
  442.         sign = -1;
  443.         t = lb;
  444.         lb = ub;
  445.         ub = t;
  446.         t = lbf;
  447.         lbf = ubf;
  448.         ubf = t;
  449.     }
  450.     else if(delta == 0) {
  451.         if(ub > 0) {
  452.             ub = 2*ub;
  453.             lb = 0;
  454.         } 
  455.         else
  456.             if(lb < 0) {
  457.                 lb = 2*lb;
  458.                 ub = 0;
  459.             } 
  460.             else {
  461.                 ub = 1;
  462.                 lb = -1;
  463.             }
  464.     }
  465.     if(p->xf==log10 && lb>0 && ub>lb) {
  466.         z = setloglim(lbf,ubf,lb,ub);
  467.         p->xlb = z.lb;
  468.         p->xub = z.ub;
  469.         p->xmult *= z.mult;
  470.         p->xquant = z.quant;
  471.         if(setmark(mark,p)<2) {
  472.             p->xqf = lbf = ubf = 1;
  473.             lb = z.lb; ub = z.ub;
  474.         } else
  475.             return;
  476.     }
  477.     z = setlinlim(lbf,ubf,lb,ub);
  478.     if(sign > 0) {
  479.         p->xlb = z.lb;
  480.         p->xub = z.ub;
  481.     } else {
  482.         p->xlb = z.ub;
  483.         p->xub = z.lb;
  484.     }
  485.     p->xmult *= z.mult;
  486.     p->xquant = sign*z.quant;
  487. }
  488.  
  489. struct z
  490. setloglim(lbf,ubf,lb,ub)
  491. double lb,ub;
  492. {
  493.     double r,s,t;
  494.     struct z z;
  495.  
  496.     for(s=1; lb*s<1; s*=10) ;
  497.     lb *= s;
  498.     ub *= s;
  499.     for(r=1; 10*r<=lb; r*=10) ;
  500.     for(t=1; t<ub; t*=10) ;
  501.     z.lb = !lbf ? r : lb;
  502.     z.ub = !ubf ? t : ub;
  503.     if(ub/lb<100) {
  504.         if(!lbf) {
  505.             if(lb >= 5*z.lb)
  506.                 z.lb *= 5;
  507.             else if(lb >= 2*z.lb)
  508.                 z.lb *= 2;
  509.         }
  510.         if(!ubf) {
  511.             if(ub*5 <= z.ub)
  512.                 z.ub /= 5;
  513.             else if(ub*2 <= z.ub)
  514.                 z.ub /= 2;
  515.         }
  516.     }
  517.     z.mult = s;
  518.     z.quant = r;
  519.     return(z);
  520. }
  521.  
  522. struct z
  523. setlinlim(lbf,ubf,xlb,xub)
  524. int lbf,ubf;
  525. double xlb,xub;
  526. {
  527.     struct z z;
  528.     double r,s,delta;
  529.     double ub,lb;
  530.  
  531. loop:
  532.     ub = xub;
  533.     lb = xlb;
  534.     delta = ub - lb;
  535.     /*scale up by s, a power of 10, so range (delta) exceeds 1*/
  536.     /*find power of 10 quantum, r, such that delta/10<=r<delta*/
  537.     r = s = 1;
  538.     while(delta*s < 10)
  539.         s *= 10;
  540.     delta *= s;
  541.     while(10*r < delta)
  542.         r *= 10;
  543.     lb *= s;
  544.     ub *= s;
  545.     /*set r=(1,2,5)*10**n so that 3-5 quanta cover range*/
  546.     if(r>=delta/2)
  547.         r /= 2;
  548.     else if(r<delta/5)
  549.         r *= 2;
  550.     z.ub = ubf? ub: modceil(ub,r);
  551.     z.lb = lbf? lb: modfloor(lb,r);
  552.     if(!lbf && z.lb<=r && z.lb>0) {
  553.         xlb = 0;
  554.         goto loop;
  555.     }
  556.     else if(!ubf && z.ub>=-r && z.ub<0) {
  557.         xub = 0;
  558.         goto loop;
  559.     }
  560.     z.quant = r;
  561.     z.mult = s;
  562.     return(z);
  563. }
  564.  
  565. scale(p,v)
  566. register struct xy *p;
  567. struct val *v;
  568. {
  569.     double edge;
  570.  
  571.     getlim(p,v);
  572.     setlim(p);
  573.     edge = top-bot;
  574.     p->xa = p->xsize*edge/((*p->xf)(p->xub) - (*p->xf)(p->xlb));
  575.     p->xbot = bot + edge*p->xoff;
  576.     p->xtop = p->xbot + (top-bot)*p->xsize;
  577.     p->xb = p->xbot - (*p->xf)(p->xlb)*p->xa + .5;
  578. }
  579.  
  580. axes()
  581. {
  582.     register i;
  583.     int mark[50];
  584.     int xn, yn;
  585.     if(gridf==0)
  586.         return;
  587.  
  588.     line(xd.xbot,yd.xbot,xd.xtop,yd.xbot);
  589.     cont(xd.xtop,yd.xtop);
  590.     cont(xd.xbot,yd.xtop);
  591.     cont(xd.xbot,yd.xbot);
  592.     line(xd.xbot-2,yd.xbot-2,xd.xtop+2,yd.xbot-2);
  593.     cont(xd.xtop+2,yd.xtop+2);
  594.     cont(xd.xbot-2,yd.xtop+2);
  595.     cont(xd.xbot-2,yd.xbot-2);
  596.     line(xd.xbot-4,yd.xbot-4,xd.xtop+4,yd.xbot-4);
  597.     cont(xd.xtop+4,yd.xtop+4);
  598.     cont(xd.xbot-4,yd.xtop+4);
  599.     cont(xd.xbot-4,yd.xbot-4);
  600.     line(xd.xbot-6,yd.xbot-6,xd.xtop+6,yd.xbot-6);
  601.     cont(xd.xtop+6,yd.xtop+6);
  602.     cont(xd.xbot-6,yd.xtop+6);
  603.     cont(xd.xbot-6,yd.xbot-6);
  604.     line(xd.xbot-8,yd.xbot-8,xd.xtop+8,yd.xbot-8);
  605.     cont(xd.xtop+8,yd.xtop+8);
  606.     cont(xd.xbot-8,yd.xtop+8);
  607.     cont(xd.xbot-8,yd.xbot-8);
  608.  
  609.     xn = setmark(mark,&xd);
  610.     for(i=0; i<xn; i++) {
  611.         if(gridf==2)
  612.             line(mark[i],yd.xbot,mark[i],yd.xtop);
  613.         if(gridf==1) {
  614.             line(mark[i],yd.xbot,mark[i],yd.xbot+tick);
  615.             line(mark[i],yd.xtop-tick,mark[i],yd.xtop);
  616.         }
  617.     }
  618.     yn = setmark(mark,&yd);
  619.     for(i=0; i<yn; i++) {
  620.         if(gridf==2)
  621.             line(xd.xbot,mark[i],xd.xtop,mark[i]);
  622.         if(gridf==1) {
  623.             line(xd.xbot,mark[i],xd.xbot+tick,mark[i]);
  624.             line(xd.xtop-tick,mark[i],xd.xtop,mark[i]);
  625.         }
  626.     }
  627. }
  628.  
  629. setmark(xmark,p)
  630. int *xmark;
  631. register struct xy *p;
  632. {
  633.     int xn = 0;
  634.     double x,xl,xu;
  635.     double q;
  636.     if(p->xf==log10&&!p->xqf) {
  637.         for(x=p->xquant; x<p->xub; x*=10) {
  638.             submark(xmark,&xn,x,p);
  639.             if(p->xub/p->xlb<=100) {
  640.                 submark(xmark,&xn,2*x,p);
  641.                 submark(xmark,&xn,5*x,p);
  642.             }
  643.         }
  644.     } else {
  645.         xn = 0;
  646.         q = p->xquant;
  647.         if(q>0) {
  648.             xl = modceil(p->xlb+q/6,q);
  649.             xu = modfloor(p->xub-q/6,q)+q/2;
  650.         } else {
  651.             xl = modceil(p->xub-q/6,q);
  652.             xu = modfloor(p->xlb+q/6,q)-q/2;
  653.         }
  654.         for(x=xl; x<=xu; x+=fabs(p->xquant))
  655.             xmark[xn++] = (*p->xf)(x)*p->xa + p->xb;
  656.     }
  657.     return(xn);
  658. }
  659. submark(xmark,pxn,x,p)
  660. int *xmark;
  661. int *pxn;
  662. double x;
  663. struct xy *p;
  664. {
  665.     if(1.001*p->xlb < x && .999*p->xub > x)
  666.         xmark[(*pxn)++] = log(x)/log((double)10)*p->xa + p->xb;
  667. }
  668.  
  669. plot()
  670. {
  671.     int ix,iy;
  672.     int i;
  673.     int conn;
  674.  
  675.     conn = 0;
  676.     if(mode!=0)
  677.         linemod(modes[mode]);
  678.     for(i=0; i<n; i++) {
  679.         if(!conv(xx[i].xv,&xd,&ix) ||
  680.            !conv(xx[i].yv,&yd,&iy)) {
  681.             conn = 0;
  682.             continue;
  683.         }
  684.         if(mode!=0) {
  685.             if(conn != 0)
  686.                 cont(ix,iy);
  687.             else
  688.                 move(ix,iy);
  689.             conn = 1;
  690.         }
  691.         conn &= symbol(ix,iy,xx[i].lblptr);
  692.     }
  693.     linemod(modes[1]);
  694. }
  695.  
  696. conv(xv,p,ip)
  697. double xv;
  698. register struct xy *p;
  699. int *ip;
  700. {
  701.     long ix;
  702.     ix = p->xa*(*p->xf)(xv*p->xmult) + p->xb;
  703.     if(ix<p->xbot || ix>p->xtop)
  704.         return(0);
  705.     *ip = ix;
  706.     return(1);
  707. }
  708.  
  709. getdouble(p)
  710. double *p;
  711. {
  712.     register i;
  713.  
  714.     i = scanf("%lf",p);
  715.     return(i==1);
  716. }
  717.  
  718. getstring()
  719. {
  720.     register i;
  721.     char junk[20];
  722.     i = scanf("%1s",labbuf);
  723.     if(i==-1)
  724.         return(-1);
  725.     switch(*labbuf) {
  726.     default:
  727.         if(!isdigit(*labbuf)) {
  728.             ungetc(*labbuf,stdin);
  729.             i = scanf("%s",labbuf);
  730.             break;
  731.         }
  732.     case '.':
  733.     case '+':
  734.     case '-':
  735.         ungetc(*labbuf,stdin);
  736.         return(0);
  737.     case '"':
  738.         i = scanf("%[^\"\n]",labbuf);
  739.         scanf("%[\"]",junk);
  740.         break;
  741.     }
  742.     if(i==-1)
  743.         return(-1);
  744.     return(strlen(labbuf));
  745. }
  746.  
  747.  
  748. symbol(ix,iy,k)
  749. {
  750.  
  751.     if(symbf==0&&k<0) {
  752.         if(mode==0)
  753.             point(ix,iy);
  754.         return(1);
  755.     } 
  756.     else {
  757.         if( strcmp(plotsymb,".") == 0 ){
  758.             move(ix-18,iy-4);
  759.         }
  760.         else{
  761.             move(ix,iy);
  762.         }
  763.         label(k>=0?labs+k:plotsymb);
  764.         move(ix,iy);
  765.         return(!brkf|k<0);
  766.     }
  767. }
  768.  
  769. title()
  770. {
  771.     int i,iy;
  772.     iy = 1300;
  773.     for(i=0;i<MAXLINE;i++){
  774.         move(xd.xbot+50,yd.xtop+iy);
  775.         if (titlebuf[i][0]) {
  776.             label(titlebuf[i]);
  777.             iy -= 70;
  778.         }
  779.     }
  780.     iy -= 70;
  781.     if(erasf&&gridf) {
  782.         move(xd.xbot+50,yd.xtop+iy);
  783.         axlab('x',&xd);
  784.         label("  ");
  785.         axlab('y',&yd);
  786.     }
  787. }
  788.  
  789. axlab(c,p)
  790. char c;
  791. struct xy *p;
  792. {
  793.     char buf[50];
  794.     sprintf(buf,"%g -%s%c- %g", p->xlb/p->xmult,
  795.         p->xf==log10?"log ":"", c, p->xub/p->xmult);
  796.     label(buf);
  797. }
  798.  
  799. badarg()
  800. {
  801.     fprintf(stderr,"graph: error in arguments\n");
  802.     exit(1);
  803. }
  804.